{{- $version := "0.68.0" }}
image: {{ $.ModuleName }}/{{ $.ImageName }}
fromImage: common/distroless
import:
- artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
  add: /prometheus-operator/operator
  to: /bin/operator
  before: setup
docker:
  ENTRYPOINT: ["/bin/operator"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
from: {{ $.Images.BASE_GOLANG_20_BULLSEYE_DEV }}
git:
  - add: /{{ $.ModulePath }}modules/200-{{ $.ModuleName }}/images/{{ $.ImageName }}/patches
    to: /patches
    stageDependencies:
      install:
        - '**/*'
mount:
- fromPath: ~/go-pkg-cache
  to: /go/pkg
shell:
  install:
    - export GOPROXY={{ $.GOPROXY }}
    - export GOOS=linux
    - export GOARCH=amd64
    - export CGO_ENABLED=0
    - git clone --depth 1 --branch "v{{ $version }}" {{ $.SOURCE_REPO }}/prometheus-operator/prometheus-operator.git /prometheus-operator
    - cd /prometheus-operator
    - export VERSION=$(cat VERSION | tr -d " \t\n\r")
    - export GO_BUILD_LDFLAGS="-X github.com/prometheus/common/version.Version=${VERSION} -X github.com/prometheus/common/version.BuildUser=deckhouse"
    - test -d /patches && for patchfile in /patches/*.patch ; do patch -p1 < ${patchfile}; done
    - go get golang.org/x/net@v0.17.0
    - go mod tidy
    - go build -ldflags="-s -w ${GO_BUILD_LDFLAGS}" -o operator cmd/operator/main.go
    - chmod 0700 /prometheus-operator/operator
    - go build -ldflags="-s -w ${GO_BUILD_LDFLAGS}" -o prometheus-config-reloader cmd/prometheus-config-reloader/main.go
    - chmod 0700 /prometheus-operator/prometheus-config-reloader
    - chown -R 64535:64535 /prometheus-operator/
